{% extends "base.html" %}
{% block content %}
<script>
$(function() {
  //Apply only when we reload the same page
  if (document.referrer === document.URL){
    //for bootstrap 3 use 'shown.bs.tab' instead of 'shown' in the next line
    $('a[data-toggle="tab"]').on('click', function (e) {
      localStorage.setItem('lastAnalysisTab', $(e.target).attr('href'));
    });

    var lastAnalysisTab = localStorage.getItem('lastAnalysisTab');

    if (lastAnalysisTab) {
        $('a[href="'+lastAnalysisTab+'"]').click();
    }
  }
  // ajax req for some tabs
  $('[data-toggle="tabajax"]').click(function(e) {
    var $this = $(this),
        url = $(this).attr("data-url");

    if (typeof url !== "undefined") {
        var pane = $(this), href = this.hash;
        $(href).load(url,function(result){
            pane.tab('show');
        });
    } else {
         $(this).tab('show');
    }
    return false;
    });
    //end
});
</script>
<style type="text/css">
.alert-tlp_green {
    background-color: #008000;
    padding: 3px;
    padding-left: 10px;
    margin-bottom: 3px;
    text-align: center;
    font-size: 12;
}
.alert-tlp_amber {
    background-color: #FFBF00;
    padding: 3px;
    padding-left: 10px;
    margin-bottom: 3px;
    text-align: center;
    font-size: 12;
}
.alert-tlp_red {
    background-color: #FF2626;
    padding: 3px;
    padding-left: 10px;
    margin-bottom: 3px;
    text-align: center;
    font-size: 12;
}
</style>
{% if analysis.info.tlp %}
    {% if analysis.info.tlp == "Red" %}
    <div class="alert alert-tlp_red">
    {% elif analysis.info.tlp == "Amber" %}
    <div class="alert alert-tlp_amber">
    {% elif analysis.info.tlp == "Green" %}
        <div class="alert alert-tlp_amber">
    {% endif %}
    </div>
{% endif %}

<ul class="nav nav-tabs">
    <li class="nav-item"><a class="nav-link active" href="#overview" data-toggle="tab">Quick Overview</a></li>
    {% if analysis.info.machine.platform == "linux" %}
        <li class="nav-item"><a class="nav-link" href="#strace" data-toggle="tabajax" data-url="/analysis/load_files/{{analysis.info.id}}/strace/" data-toggle="tab">Behavioral Analysis</a></li>
        <li class="nav-item"><a class="nav-link" href="#tracee" data-toggle="tabajax" data-url="/analysis/load_files/{{analysis.info.id}}/tracee/" data-toggle="tab">Detailed Behaviour (Tracee)</a></li>
    {% elif analysis.info.category != "pcap" and analysis.info.category != "static" %}
        <li class="nav-item"><a class="nav-link" href="#behavior" data-toggle="tabajax" data-url="/analysis/load_files/{{analysis.info.id}}/behavior/" data-toggle="tab">Behavioral Analysis</a></li>
    {% endif %}
    {% if analysis.info.category != "static" %}
        <li class="nav-item"><a class="nav-link" href="#network" data-toggle="tabajax" data-url="/analysis/load_files/{{analysis.info.id}}/network/" data-toggle="tab">Network Analysis</a></li>
    {% endif %}
    {% if analysis.info.category != "pcap" and analysis.info.category != "static" %}
        {% if analysis.dropped %}
            <li class="nav-item"><a class="nav-link" href="#dropped" data-toggle="tabajax" data-url="/analysis/load_files/{{analysis.info.id}}/dropped/" data-toggle="tab">Dropped Files ({{analysis.dropped}})</a></li>
        {% endif %}
        {% if analysis.static.pe.overlay.fileinfo %}
            <li class="nav-item"><a class="nav-link" href="#overlay" data-toggle="tab">Overlay data</a></li>
        {% endif %}
        {% if analysis.procmemory %}
            <li class="nav-item"><a class="nav-link" href="#procmemory" data-toggle="tabajax" data-url="/analysis/load_files/{{analysis.info.id}}/procmemory/" data-toggle="tab" >Process Memory ({{analysis.procmemory}})</a></li>
        {% endif %}
        {% if analysis.memory %}
            <li class="nav-item"><a class="nav-link" href="#memory" data-toggle="tabajax" data-url="/analysis/load_files/{{analysis.info.id}}/memory/" data-toggle="tab">Memory Analysis</a></li>
        {% endif %}
        {% if analysis.procdump %}
            <li class="nav-item"><a class="nav-link" href="#procdump" data-toggle="tabajax" data-url="/analysis/load_files/{{analysis.info.id}}/procdump/">Process Dumps ({{analysis.procdump}})</a></li>
        {% endif %}
        {% if analysis.CAPE %}
            <li class="nav-item"><a class="nav-link" href="#CAPE" data-toggle="tabajax" data-url="/analysis/load_files/{{analysis.info.id}}/CAPE/" data-toggle="tab">Payloads ({{analysis.CAPE}})</a></li>
        {% endif%}
        {% if analysis.debugger_logs %}
            <li class="nav-item"><a class="nav-link" href="#debugger" data-toggle="tabajax" data-url="/analysis/load_files/{{analysis.info.id}}/debugger/" data-toggle="tab">Debugger</a></li>
        {% endif %}
    {% endif %}
    {% if settings.COMMENTS %}
        {% if analysis.info.comments|length %}
            <li class="nav-item"><a class="nav-link" href="#comments" data-toggle="tab">Comments ({{analysis.info.comments|length}})</a></li>
        {% else %}
            <li class="nav-item"><a class="nav-link" href="#comments" data-toggle="tab">Comments</a></li>
        {% endif %}
    {% endif %}
    {% if analysis.misp %}
            <li class="nav-item"><a class="nav-link" href="#misp" data-toggle="tab">MISP</a></li>
    {% endif %}
    {% if analysis.backscatter %}<li class="nav-item"><a class="nav-link" href="#backscatter" data-toggle="tab">Backscatter</a></li>{% endif %}
    {% if analysis.classification%}<li class="nav-item"><a class="nav-link" href="#classification" data-toggle="tab">Classification</a> </li>{% endif %}
     {% if analysis.info.category == "file" and analysis.target %}<li class="nav-item"><a class="nav-link" href="{% url "compare_left" analysis.info.id %}">Compare this analysis to...</a></li>{% endif %}
    {% if settings.ADMIN or user.is_staff %}<li class="nav-item"><a class="nav-link" href="#admin" data-toggle="tab">Admin</a></li>{% endif %}
</ul>
<div class="tab-content">
    <div class="tab-pane fade show active" id="overview">
        {% include "analysis/overview/index.html" %}
    </div>
    <div class="tab-pane fade" id="behavior">
        {% include "analysis/behavior/index.html" %}
    </div>
    <div class="tab-pane fade" id="strace">
        {% include "analysis/strace/index.html" %}
    </div>
    <div class="tab-pane fade" id="tracee">
        {% include "analysis/tracee/index.html" %}
    </div>
    <div class="tab-pane fade" id="network">
        {% include "analysis/network/index.html" %}
    </div>
    <div class="tab-pane fade" id="dropped">
        {% include "analysis/dropped/index.html" %}
    </div>
    {% if analysis.CAPE %}
        <div class="tab-pane fade" id="CAPE">
        {% include "analysis/CAPE/index.html" %}
        </div>
    {% endif %}
    <div class="tab-pane fade" id="procdump">
        {% include "analysis/procdump/index.html" %}
    </div>
    {% if analysis.procmemory %}
    <div class="tab-pane fade" id="procmemory">
        {% include "analysis/procmemory/index.html" %}
    </div>
    {% endif %}
    {% if analysis.memory %}
        <div class="tab-pane fade" id="memory">
            {% include "analysis/memory/index.html" %}
        </div>
    {% endif %}
    {% if config.malheur %}
        {% if analysis.info.category == "file" or analysis.info.category == "url" %}
        <div class="tab-pane fade" id="similar">
            {% include "analysis/similar/index.html" %}
        </div>
        {% endif %}
    {% endif %}
    {% if settings.COMMENTS %}
    <div class="tab-pane fade" id="comments">
        {% include "analysis/comments/index.html" %}
    </div>
    {% endif %}
    {% if analysis.misp %}
    <div class="tab-pane fade" id="misp">
        {% include "analysis/misp/index.html" %}
    </div>
    {% endif %}
    {% if analysis.debugger_logs %}
        <div class="tab-pane fade" id="debugger">
            {% include "analysis/debugger/index.html" %}
        </div>
    {% endif %}
    {% if analysis.backscatter %}
    <div class="tab-pane fade" id="backscatter">
        {% include "analysis/backscatter.html" %}
    </div>
    {% endif %}
    {% if analysis.classification %}
    <div class="tab-pane fade" id="classification">
        {% include "analysis/classification.html" %}
    </div>
    {% endif %}
    {% if settings.ADMIN or user.is_staff %}
    <div class="tab-pane fade" id="admin">
        {% include "analysis/admin/index.html" %}
    </div>
    {% endif %}
    {% if analysis.static.pe.overlay.fileinfo %}
    <div class="tab-pane fade" id="overlay">
        {% include "analysis/overlay/index.html" %}
    </div>
    {% endif %}
</div>
{% endblock %}
